from flask import Flask
import subprocess

app=Flask(__name__)

@app.route('/')
def index():
    return '<h1>Hello world!</h1>'

@app.route('/user/<name>')
def user(name):
    return '<h1>Hello,{}!</h1>'.format(name)

@app.route('/test')
def test():
    # 调用python2
    exe = ['D:\Python27\python.exe', '--version']
    rtn = subprocess.run(exe, stdout=subprocess.PIPE)
    msg = rtn.stdout.decode('utf-8')
    print(msg)
    return u'result: {}'.format(msg)


if __name__ == '__main__':
    app.run(debug=True, use_debugger=False, use_reloader=False, passthrough_errors=True)

